<%@ page pageEncoding="UTF-8"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="isperp" uri="/WEB-INF/tlds/isperp.tld"%>

<script type="text/javascript">
	function changeName() {
		$.ajax({
			url : 'individuation/individuationForm/getPinYin?src=' + $("#processName").val(),
			success : function(data) {
				if (data)
					$("#processKey").val(data);
			}
		});
	}
</script>

<input type="text" id="modelId" style="display:none"/>

<div id="createWizard" class="wizard box tabbedBox no-border">

	<div class="header">
		<ul class="steps">
			<li><a class="current" href="#wiz_tab1">1、流程定义</a></li>
			<li><a href="#wiz_tab2">2、流程设计</a></li>
			<li><a href="#wiz_tab3">3、流程配置</a></li>
		</ul>
	</div>
	<div class="content tabbed" style="padding:0">
		<div id="wiz_tab1">
			<table class="form-table">
				<tr>
					<td class="td1">流程名称：</td>
					<td class="td2"><input type="text" id="processName"
						class="required" onkeydown="changeName()" onkeyup="changeName()">
					</td>
				</tr>
				<tr>
					<td class="td1">流程Key：</td>
					<td class="td2"><input type="text" id="processKey"
						class="required"></td>
				</tr>
				<tr>
					<td class="td1">关联表单：</td>
					<td class="td2"><input id="relateFormId" style="display:none"> <isperp:listSelector
							autocomplete="false" id="relateFormIdSelector"
							displayColumn="name" valueColumn="id" displayValue=""
							valueControlId="relateFormId" displayValueCssClass="required"
							url="individuation/individuationForm/listDetail">
							<isperp:column name="id" title="id" hidden="true"></isperp:column>
							<isperp:column name="name" title="名称" width="90">
							</isperp:column>
						</isperp:listSelector>
					</td>
				</tr>
			</table>

		</div>

		<div id="wiz_tab2" style="width:100%;">
			 <iframe src="" width="100%"
				height="800px" id="frm1"> </iframe> 

		</div>
		<div id="wiz_tab3">
			<iframe
				src=""
				width="100%" height="800px" id="frm2"> </iframe>
		</div>
	</div>
	<isperp:wizButtonList buttonListId="bpmConfigWizardBtns">
	</isperp:wizButtonList>
</div>


<script type="text/javascript">
	var wizCreate = isperp.wizard({
		wizardId : "createWizard"
	});
	var createWizard_Event1 = function(index, obj) {
		var processKey = $("#processKey").val();
		$.post("workflow/processDefinition/deployNewProcess", {
			processKey : processKey,
			processName : $("#processName").val(),
			fomrId : $("#relateFormId").val()
		}, function(data) {
			//$("#wiz_tab2").empty().load("workflow/modeler.jsp?modelId="+data.data);
			$("#modelId").val(data.data);
			$("#frm1").attr("src","workflow/modeler.jsp?modelId="+data.data);
		});

	};

	var createWizard_Event2 = function(index, obj) {
		var processKey=$("#processKey").val();
		var modelId=$("#modelId").val();
		$.get("workflow/bpmnModel/iddDeploy", {
			processKey : processKey,
			modelId:modelId
		}, function(data) {
			if (data && data.success == false) {
				isperp.warnAlert(data.data);
			} else {
				isperp.tooltip("流程部署成功！");
				$("#frm2").attr("src","bpm/processSetting/iddEdit?processKey="+processKey);
			}
		});

	};

	var createWizard_Event3 = function(index, obj) {

	};
</script>